<?php
error_reporting(0);
$page="Index Page";
include "include/trafic.php";
$page=$_GET['page'];
if ($page==""){
$page=0;
}
$q=$page*10;

include "include/header.php";
navigation();
include "include/config.php";
?>

<div id="main">

<?PHP

include  "include/bar.php";
?>

<div id="post">

<?PHP
$link=mysql_connect($hostname,$username,$password)or die("Failed");
mysql_select_db($database)or die("Failed");
$rowcount =mysql_query("SELECT COUNT(*) FROM gb_posts where status='PUBLISH'");
$num = mysql_fetch_array($rowcount, MYSQL_ASSOC);
$num_rows=$num['COUNT(*)'];
if ($num_rows==0){
                                $icon="stop.gif";
                                $mhead="gBLOG!"; 
				$mbody="There is No Post to show!";
				include "include/msgbox.php";
}
else
{
$result=mysql_query("SELECT * FROM gb_posts where status='PUBLISH' order by id desc LIMIT $q,10")or Die("<p align=center><font size=4pt><bold>Sorry but you've not Installed gBLOG on Your server<br>Read instrcution to Install gBLOG.</bold></font></p>");

while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
{
$ptitle=$row['title'];
$bid=$row['id'];
$body=$row['body'];
$author=$row['author'];
$cmt=$row['cmt'];
$dt=$row['date'];
$t=$row['time'];
$stat=$row['stat'];
$cid=$row['catid'];
$cat=GetCatName($cid);

include "include/post_index.php";
}
}
mysql_close($link);

echo "<div id=\"art\">";
if($num_rows-10>$page*10){
$np=$page+1;
print "&nbsp;&nbsp;<a   href=index.php?page=" .$np .">Next Page</a>";
}

if($page+1*10>10){
$bp=$page-1;
print "&nbsp;&nbsp;<a   href=index.php?page=" .$bp .">&nbsp;Back Page</a>";

}
echo "</div>";
?>
</div>
<div style = "clear: both;"></div></div>
<?PHP
include "include/fotter.php";


 ?>
<?PHP

function GetCatName($cid)
{
include "include/config.php";
$link=mysql_connect($hostname,$username,$password)or die("Failed");
mysql_select_db($database)or die("Failed");

$result =mysql_query("SELECT * FROM gb_cat where id='$cid'");
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$cat=$row['name'];
return $cat;

}
function navigation()
{
 echo "<div align=\"center\" id=\"navigition\"><div id=\"nav\">";
include "include/config.php";
$link=mysql_connect($hostname,$username,$password)or die("Failed");
mysql_select_db($database)or die("Failed");
$rowcount =mysql_query("SELECT COUNT(*) FROM gb_links");
$num = mysql_fetch_array($rowcount, MYSQL_ASSOC);
$nr=$num['COUNT(*)'];

$c=1;

$result =mysql_query("SELECT * FROM gb_links");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if ($c<>$nr)
{
$u=" | ";
}
else
{
$u="";
}
$link=$row['link'];
$url=$row['url'];

echo "<a href=" .$url .">" .$link ."</a>&nbsp;" . $u ."&nbsp;";
$c=$c+1;
}
echo "</div></div>";
}
?>

